home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 3 / BBS in a box - Trilogy III.iso / Files / Prog / B-C / C++Source Code Fmtr Folder / Src / DFile.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-04-27  |  1.6 KB  |  98 lines  |  [TEXT/MPS ]

  1. #ifndef __DFILE__
  2. #define __DFILE__    1
  3.  
  4. #ifndef __DATAAREA__
  5. #include "DataArea.h"
  6. #endif
  7.  
  8. #ifndef __STDFILE__
  9. #include "StdFile.h"
  10. #endif
  11.  
  12.  
  13.  
  14. #pragma segment DFile
  15.  
  16.  
  17. /*µ class DFile
  18. **    This class binds a DataArea with a StdFile.  The DataArea is written to
  19. ** using the normal DataArea methods.  The Flush() method is called to copy
  20. ** the data from the DataArea to the output file.  The purpose of this class
  21. ** is to enable cheap undo-able writes for the Formatting class
  22. */
  23. class DFile : public DataArea {
  24. public:
  25.     DFile();
  26.  
  27.     short IDFile(const DFile *anArea);
  28.     short IDFile(size_t initialSize = 0, size_t increment = 0);
  29.     // Construct the DFile.
  30.  
  31.  
  32.     void SetOutput(StdFile *anOutput);
  33.     /*
  34.     ** Set the StdFile to which output is written
  35.     */
  36.  
  37.  
  38.     void Putc(int aChar);
  39.     void Puts(const char *aString);
  40.     /*
  41.     ** Routines to write to the data buffer
  42.     */
  43.  
  44.  
  45.     void Rewind();
  46.  
  47.  
  48.     size_t Flush(size_t aThreshold = 0);
  49.     /*
  50.     ** Write the data in the DataArea to fOutput if the amount of data
  51.     ** exceed aThreshold.  Once written, the data cannot be re-written.
  52.     */
  53.  
  54.     int Error() const;
  55.     // Return the error that might have occurred during Flush()
  56.  
  57. private:
  58.     StdFile *fOutput;
  59. };
  60.  
  61.  
  62. //µ   DFile::DFile
  63. #pragma segment DFile
  64. inline DFile::DFile()
  65.     : DataArea(),
  66.       fOutput(0)
  67.     {
  68.     }
  69.  
  70.  
  71. //µ   DFile::IDFile
  72. #pragma segment DFile
  73. inline short DFile::IDFile(size_t initialSize, size_t increment)
  74. {
  75.     return (IDataArea(initialSize, increment));
  76. }
  77.  
  78.  
  79. //µ   DFile::Rewind
  80. #pragma segment DFile
  81. inline void DFile::Rewind()
  82. {
  83.     SetCursor(0);
  84. }
  85.  
  86.  
  87. //µ   DFile::Error
  88. #pragma segment DFile
  89. inline int DFile::Error() const
  90. {
  91.     return (fOutput->Error());
  92. }
  93.  
  94.  
  95. #endif
  96.  
  97.  
  98.